/*设计一个鸟（bird）类，设计纯虚方法fly(),
分别有大雁类（Wildgoose）、鹦鹉类（Parrot）,
设计一个鸟笼类（birdCage）保存所有的鸟类对象（推荐使用vector）
，然后设计一个方法，让所有的鸟类飞翔。
【4分：继承+虚函数重写2分，对象的保存1分，所有的动物的飞行1分】*/
#include <iostream>
#include <vector>
using namespace std;
#include <string>
#include <memory>

//bird
class bird
{
private:
public:
    bird(){}
    ~bird(){}
    virtual void fly() = 0;
};

class wildgoose:public bird
{
private:
    string name;
public:
    wildgoose(string name)
    :name(name){}
    ~wildgoose(){}
    void fly()
    {
        cout<<"wildgoose "<<name<<" is flying!"<<endl;
    }
};

class parrot:public bird
{
private:
    string name;
public:
    parrot(string name)
    :name(name){}
    ~parrot(){}
    void fly()
    {
        cout<<"parrot "<<name<<" is flying!"<<endl;
    }
};

class birdCage
{
private:
    vector<bird*> a;
public:
    birdCage(){}
    ~birdCage(){}
    void addWild()
    {
        string n;
        cout<<"please input wildgoose name :";
        cin>>n;
        bird*p =new wildgoose(n);
        a.push_back(p);
    }
    void addParrot()
    {
        string n;
        cout<<"please input parrot name :";
        cin>>n;
        bird*p =new parrot(n);
        a.push_back(p);
    }
    void allFly()
    {
        if(a.size() != 0)
        {
            for(int i=0;i<a.size();i++)
            {
                a[i]->fly();
            }
        }
    }
};

int main(int argc,char*argv[])
{
    birdCage b;
    b.addParrot();
    b.addWild();
    b.allFly();

    return 0;
}
